Page({
  data: {
    swiperList: [],
    catitemList: []
  },
  onLoad: function () {
    //获取轮播图数据
    this.getSwiperList();
    //获取导航数据
    this.getCatitems();
    //获取分类数据
    this.getCatitems();
  },
  changeUrlData:function(data){
     return data.map(item=>(item.navigator_url).replace("main","index"))
  },
  getSwiperList: async function () {
    let { data } = await wx.homeApi.getSwiperData();
  //更新接口数据的跳转URL
    data.message.map(item=>item.navigator_url = (item.navigator_url).replace("main","index"))
    this.setData({
      swiperList: data.message
    })
  },

  //home/catitems
  getCatitems: async function () {
    let { data } = await wx.homeApi.getCatitems();
    // let { data } = await wx.$http({ url: "home/catitems" });
    this.setData({
      catitemList: data.message
    })
  }
})
